package com.auth.manage.order.domain.validator;

import com.auth.manage.base.responce.MultipleResponce;
import com.auth.manage.common.order.api.request.OrderCreateRequest;
import com.auth.manage.common.user.api.request.condition.UserQueryByUserIdCondition;
import com.auth.manage.common.user.api.responce.UserResponce;
import com.auth.manage.common.user.api.service.UserFacadeService;
import lombok.RequiredArgsConstructor;

// todo 确定用户角色、权限、状态，责任链模式完成下单
@RequiredArgsConstructor
public class UserValidator extends OrderCreateValidator{
    private UserFacadeService userFacadeService;
    @Override
    void setNext(OrderCreateValidator orderCreateValidator) {
        this.orderCreateValidator = orderCreateValidator;
    }

    @Override
    void validate(OrderCreateRequest request) {
        Long buyerId = request.getBuyerId();
        UserQueryByUserIdCondition condition = new UserQueryByUserIdCondition(buyerId);
        MultipleResponce<UserResponce> responce = userFacadeService.queryByCondition(condition);
        if (responce.getSuccess()){
            responce.getData().stream().findFirst().ifPresentOrElse(userResponce -> {

            },()->{

            });
        }
    }
}
